@uiw/react-md-editor 3.18.3 → 3.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mdeditor.js +5 -5
- package/dist/mdeditor.min.js +1 -1
- package/esm/commands/code.js +4 -4
- package/esm/commands/code.js.map +1 -1
- package/esm/commands/comment.js +23 -12
- package/esm/commands/comment.js.map +2 -2
- package/esm/commands/image.js +2 -2
- package/esm/commands/image.js.map +1 -1
- package/esm/commands/index.js +6 -6
- package/esm/commands/index.js.map +2 -2
- package/lib/commands/code.js +4 -4
- package/lib/commands/code.js.map +1 -1
- package/lib/commands/comment.js +23 -12
- package/lib/commands/comment.js.map +2 -2
- package/lib/commands/image.js +2 -2
- package/lib/commands/image.js.map +1 -1
- package/lib/commands/index.js +6 -6
- package/lib/commands/index.js.map +3 -3
- package/package.json +1 -1
- package/src/commands/code.tsx +2 -2
- package/src/commands/comment.tsx +19 -4
- package/src/commands/image.tsx +1 -1
- package/src/commands/index.ts +5 -6
package/dist/mdeditor.js
CHANGED
|
@@ -62620,16 +62620,16 @@ var newSelectionRange=selectWord({text:state.text,selection:state.selection});va
|
|
|
62620
62620
|
var state2=api.replaceSelection("**".concat(state1.selectedText,"**"));// Adjust the selection to not contain the **
|
|
62621
62621
|
api.setSelectionRange({start:state2.selection.end-2-state1.selectedText.length,end:state2.selection.end-2});}};
|
|
62622
62622
|
;// CONCATENATED MODULE: ./src/commands/code.tsx
|
|
62623
|
-
var code_code={name:'code',keyCommand:'code',shortcuts:'ctrlcmd+j',value:'``',buttonProps:{'aria-label':'Insert code (ctrl + j)',title:'Insert code (ctrl + j)'},icon:/*#__PURE__*/(0,jsx_runtime.jsx)("svg",{width:"
|
|
62623
|
+
var code_code={name:'code',keyCommand:'code',shortcuts:'ctrlcmd+j',value:'``',buttonProps:{'aria-label':'Insert code (ctrl + j)',title:'Insert code (ctrl + j)'},icon:/*#__PURE__*/(0,jsx_runtime.jsx)("svg",{width:"14",height:"14",role:"img",viewBox:"0 0 640 512",children:/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"currentColor",d:"M278.9 511.5l-61-17.7c-6.4-1.8-10-8.5-8.2-14.9L346.2 8.7c1.8-6.4 8.5-10 14.9-8.2l61 17.7c6.4 1.8 10 8.5 8.2 14.9L293.8 503.3c-1.9 6.4-8.5 10.1-14.9 8.2zm-114-112.2l43.5-46.4c4.6-4.9 4.3-12.7-.8-17.2L117 256l90.6-79.7c5.1-4.5 5.5-12.3.8-17.2l-43.5-46.4c-4.5-4.8-12.1-5.1-17-.5L3.8 247.2c-5.1 4.7-5.1 12.8 0 17.5l144.1 135.1c4.9 4.6 12.5 4.4 17-.5zm327.2.6l144.1-135.1c5.1-4.7 5.1-12.8 0-17.5L492.1 112.1c-4.8-4.5-12.4-4.3-17 .5L431.6 159c-4.6 4.9-4.3 12.7.8 17.2L523 256l-90.6 79.7c-5.1 4.5-5.5 12.3-.8 17.2l43.5 46.4c4.5 4.9 12.1 5.1 17 .6z"})}),execute:function execute(tate,api){// Adjust the selection to encompass the whole word if the caret is inside one
|
|
62624
62624
|
var newSelectionRange=selectWord({text:tate.text,selection:tate.selection});var state1=api.setSelectionRange(newSelectionRange);// when there's no breaking line
|
|
62625
62625
|
if(state1.selectedText.indexOf('\n')===-1){api.replaceSelection("`".concat(state1.selectedText,"`"));// Adjust the selection to not contain the **
|
|
62626
|
-
var _selectionStart=state1.selection.start+1;var _selectionEnd=_selectionStart+state1.selectedText.length;api.setSelectionRange({start:_selectionStart,end:_selectionEnd});return;}var breaksBeforeCount=getBreaksNeededForEmptyLineBefore(state1.text,state1.selection.start);var breaksBefore=Array(breaksBeforeCount+1).join('\n');var breaksAfterCount=getBreaksNeededForEmptyLineAfter(state1.text,state1.selection.end);var breaksAfter=Array(breaksAfterCount+1).join('\n');api.replaceSelection("".concat(breaksBefore,"```\n").concat(state1.selectedText,"\n```").concat(breaksAfter));var selectionStart=state1.selection.start+breaksBeforeCount+4;var selectionEnd=selectionStart+state1.selectedText.length;api.setSelectionRange({start:selectionStart,end:selectionEnd});}};var codeBlock={name:'codeBlock',keyCommand:'codeBlock',shortcuts:'ctrlcmd+shift+j',value:'```\n```',icon:/*#__PURE__*/(0,jsx_runtime.jsx)("svg",{width:"
|
|
62626
|
+
var _selectionStart=state1.selection.start+1;var _selectionEnd=_selectionStart+state1.selectedText.length;api.setSelectionRange({start:_selectionStart,end:_selectionEnd});return;}var breaksBeforeCount=getBreaksNeededForEmptyLineBefore(state1.text,state1.selection.start);var breaksBefore=Array(breaksBeforeCount+1).join('\n');var breaksAfterCount=getBreaksNeededForEmptyLineAfter(state1.text,state1.selection.end);var breaksAfter=Array(breaksAfterCount+1).join('\n');api.replaceSelection("".concat(breaksBefore,"```\n").concat(state1.selectedText,"\n```").concat(breaksAfter));var selectionStart=state1.selection.start+breaksBeforeCount+4;var selectionEnd=selectionStart+state1.selectedText.length;api.setSelectionRange({start:selectionStart,end:selectionEnd});}};var codeBlock={name:'codeBlock',keyCommand:'codeBlock',shortcuts:'ctrlcmd+shift+j',value:'```\n```',icon:/*#__PURE__*/(0,jsx_runtime.jsx)("svg",{width:"13",height:"13",role:"img",viewBox:"0 0 156 156",children:/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"currentColor",d:"M110.85 120.575 43.7 120.483333 43.7083334 110.091667 110.85 110.191667 110.841667 120.583333 110.85 120.575ZM85.1333334 87.1916666 43.625 86.7083332 43.7083334 76.3166666 85.2083334 76.7916666 85.1333334 87.1916666 85.1333334 87.1916666ZM110.841667 53.4166666 43.7 53.3166666 43.7083334 42.925 110.85 43.025 110.841667 53.4166666ZM36 138C27.2916666 138 20.75 136.216667 16.4 132.666667 12.1333334 129.2 10 124.308333 10 118L10 95.3333332C10 91.0666666 9.25 88.1333332 7.7333334 86.5333332 6.3166668 84.8416666 3.7333334 84 0 84L0 72C3.7333334 72 6.3083334 71.2 7.7333334 69.6 9.2416668 67.9083334 10 64.9333334 10 60.6666666L10 38C10 31.775 12.1333334 26.8833334 16.4 23.3333332 20.7583334 19.7749998 27.2916666 18 36 18L40.6666668 18 40.6666668 30 36 30C34.0212222 29.9719277 32.1263151 30.7979128 30.8 32.2666666 29.3605875 33.8216362 28.5938182 35.8823287 28.6666668 38L28.6666668 60.6666666C28.6666668 67.5083332 26.6666668 72.4 22.6666668 75.3333332 20.9317416 76.7274684 18.8640675 77.6464347 16.6666668 78 18.8916668 78.35 20.8916668 79.2416666 22.6666668 80.6666666 26.6666668 83.95 28.6666668 88.8416666 28.6666668 95.3333332L28.6666668 118C28.6666668 120.308333 29.3750002 122.216667 30.8 123.733333 32.2166666 125.241667 33.9583334 126 36 126L40.6666668 126 40.6666668 138 36 138 36 138ZM114.116667 126 118.783333 126C120.833333 126 122.566667 125.241667 123.983333 123.733333 125.422746 122.178364 126.189515 120.117671 126.116667 118L126.116667 95.3333332C126.116667 88.8333332 128.116667 83.9499998 132.116667 80.6666666 133.9 79.2416666 135.9 78.35 138.116667 78 135.919156 77.6468047 133.851391 76.7277979 132.116667 75.3333332 128.116667 72.3999998 126.116667 67.5 126.116667 60.6666666L126.116667 38C126.189515 35.8823287 125.422746 33.8216361 123.983333 32.2666666 122.657018 30.7979128 120.762111 29.9719277 118.783333 30L114.116667 30 114.116667 18 118.783333 18C127.5 18 133.983333 19.775 138.25 23.3333332 142.608333 26.8833332 144.783333 31.7749998 144.783333 38L144.783333 60.6666666C144.783333 64.9333332 145.5 67.9083332 146.916667 69.6 148.433333 71.2 151.05 72 154.783333 72L154.783333 84C151.05 84 148.433333 84.8333334 146.916667 86.5333332 145.5 88.1333332 144.783333 91.0666666 144.783333 95.3333332L144.783333 118C144.783333 124.308333 142.616667 129.2 138.25 132.666667 133.983333 136.216667 127.5 138 118.783333 138L114.116667 138 114.116667 126 114.116667 126Z"})}),buttonProps:{'aria-label':'Insert Code Block (ctrl + shift + j)',title:'Insert Code Block (ctrl + shift +j)'},execute:function execute(tate,api){// Adjust the selection to encompass the whole word if the caret is inside one
|
|
62627
62627
|
var newSelectionRange=selectWord({text:tate.text,selection:tate.selection});var state1=api.setSelectionRange(newSelectionRange);var breaksBeforeCount=getBreaksNeededForEmptyLineBefore(state1.text,state1.selection.start);var breaksBefore=Array(breaksBeforeCount+1).join('\n');var breaksAfterCount=getBreaksNeededForEmptyLineAfter(state1.text,state1.selection.end);var breaksAfter=Array(breaksAfterCount+1).join('\n');api.replaceSelection("".concat(breaksBefore,"```\n").concat(state1.selectedText,"\n```").concat(breaksAfter));var selectionStart=state1.selection.start+breaksBeforeCount+4;var selectionEnd=selectionStart+state1.selectedText.length;api.setSelectionRange({start:selectionStart,end:selectionEnd});}};
|
|
62628
62628
|
;// CONCATENATED MODULE: ./src/commands/comment.tsx
|
|
62629
62629
|
var commands_comment_comment={name:'comment',keyCommand:'comment',shortcuts:'ctrlcmd+/',value:'<!-- -->',buttonProps:{'aria-label':'Insert comment (ctrl + /)',title:'Insert comment (ctrl + /)'},execute:function execute(state,api){// Adjust the selection to encompass the whole word if the caret is inside one
|
|
62630
62630
|
var newSelectionRange=selectWord({text:state.text,selection:state.selection});var state1=api.setSelectionRange(newSelectionRange);// Replaces the current selection with the bold mark up
|
|
62631
62631
|
var state2=api.replaceSelection("<!-- ".concat(state1.selectedText," -->"));// Adjust the selection to not contain the **
|
|
62632
|
-
api.setSelectionRange({start:state2.selection.end-4-state1.selectedText.length,end:state2.selection.end-4});},icon:/*#__PURE__*/(0,jsx_runtime.
|
|
62632
|
+
api.setSelectionRange({start:state2.selection.end-4-state1.selectedText.length,end:state2.selection.end-4});},icon:/*#__PURE__*/(0,jsx_runtime.jsx)("svg",{height:"1em",width:"1em",viewBox:"0 0 25 25",children:/*#__PURE__*/(0,jsx_runtime.jsxs)("g",{fill:"none",fillRule:"evenodd",children:[/*#__PURE__*/(0,jsx_runtime.jsx)("polygon",{points:".769 .727 24.981 .727 24.981 24.727 .769 24.727"}),/*#__PURE__*/(0,jsx_runtime.jsx)("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"3",d:"M12.625,23.8787879 L8.125,19.6969697 L5.125,19.6969697 C2.63971863,19.6969697 0.625,17.8247059 0.625,15.5151515 L0.625,7.15151515 C0.625,4.84196074 2.63971863,2.96969697 5.125,2.96969697 L20.125,2.96969697 C22.6102814,2.96969697 24.625,4.84196074 24.625,7.15151515 L24.625,15.5151515 C24.625,17.8247059 22.6102814,19.6969697 20.125,19.6969697 L17.125,19.6969697 L12.625,23.8787879"}),/*#__PURE__*/(0,jsx_runtime.jsx)("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"3",d:"M10.625,8.54545455 L7.25,11.3333333 L10.625,14.1212121 M15.6875,8.54545455 L19.0625,11.3333333 L15.6875,14.1212121"})]})})};
|
|
62633
62633
|
;// CONCATENATED MODULE: ./src/commands/divider.tsx
|
|
62634
62634
|
var divider={keyCommand:'divider'};
|
|
62635
62635
|
;// CONCATENATED MODULE: ./src/commands/fullscreen.tsx
|
|
@@ -62639,7 +62639,7 @@ var group=function group(arr,options){var data=_objectSpread2(_objectSpread2({ch
|
|
|
62639
62639
|
;// CONCATENATED MODULE: ./src/commands/hr.tsx
|
|
62640
62640
|
var hr={name:'hr',keyCommand:'hr',shortcuts:'ctrlcmd+h',value:'----------',buttonProps:{'aria-label':'Insert HR (ctrl + h)',title:'Insert HR (ctrl + h)'},icon:/*#__PURE__*/(0,jsx_runtime.jsx)("svg",{width:"12",height:"12",viewBox:"0 0 175 175",children:/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"currentColor",d:"M0,129 L175,129 L175,154 L0,154 L0,129 Z M3,9 L28.2158203,9 L28.2158203,47.9824219 L55.7695313,47.9824219 L55.7695313,9 L81.0966797,9 L81.0966797,107.185547 L55.7695313,107.185547 L55.7695313,68.0214844 L28.2158203,68.0214844 L28.2158203,107.185547 L3,107.185547 L3,9 Z M93.1855469,100.603516 L93.1855469,19 L135.211914,19 C143.004922,19 148.960917,19.6679621 153.080078,21.0039063 C157.199239,22.3398504 160.520495,24.8168764 163.043945,28.4350586 C165.567395,32.0532407 166.829102,36.459935 166.829102,41.6552734 C166.829102,46.1826398 165.864267,50.0883625 163.93457,53.3725586 C162.004873,56.6567547 159.351579,59.3193257 155.974609,61.3603516 C153.822255,62.6591862 150.872089,63.7353473 147.124023,64.5888672 C150.129898,65.5908253 152.319329,66.5927684 153.692383,67.5947266 C154.620122,68.2626987 155.965323,69.6913953 157.728027,71.8808594 C159.490731,74.0703234 160.668942,75.7587831 161.262695,76.9462891 L173,100.603516 L144.953125,100.603516 L131.482422,75.6660156 C129.775382,72.4374839 128.253913,70.3408251 126.917969,69.3759766 C125.0996,68.1142515 123.040051,67.4833984 120.739258,67.4833984 L118.512695,67.4833984 L118.512695,100.603516 L93.1855469,100.603516 Z M118.512695,52.0644531 L129.144531,52.0644531 C130.294928,52.0644531 132.521468,51.6933631 135.824219,50.9511719 C137.494149,50.6171858 138.857905,49.7636787 139.915527,48.390625 C140.97315,47.0175713 141.501953,45.4404386 141.501953,43.6591797 C141.501953,41.0244009 140.667001,39.0019602 138.99707,37.5917969 C137.32714,36.1816336 134.191429,35.4765625 129.589844,35.4765625 L117.512695,35.4765625 L118.512695,52.0644531 Z",transform:"translate(0 9)"})}),execute:function execute(state,api){api.replaceSelection("".concat(state.selectedText,"\n\n----------\n\n"));}};
|
|
62641
62641
|
;// CONCATENATED MODULE: ./src/commands/image.tsx
|
|
62642
|
-
var commands_image_image={name:'image',keyCommand:'image',shortcuts:'ctrlcmd+k',value:'![image]()',buttonProps:{'aria-label':'Add image (ctrl + k)',title:'Add image (ctrl + k)'},icon:/*#__PURE__*/(0,jsx_runtime.jsx)("svg",{width:"
|
|
62642
|
+
var commands_image_image={name:'image',keyCommand:'image',shortcuts:'ctrlcmd+k',value:'![image]()',buttonProps:{'aria-label':'Add image (ctrl + k)',title:'Add image (ctrl + k)'},icon:/*#__PURE__*/(0,jsx_runtime.jsx)("svg",{width:"13",height:"13",viewBox:"0 0 20 20",children:/*#__PURE__*/(0,jsx_runtime.jsx)("path",{fill:"currentColor",d:"M15 9c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm4-7H1c-.55 0-1 .45-1 1v14c0 .55.45 1 1 1h18c.55 0 1-.45 1-1V3c0-.55-.45-1-1-1zm-1 13l-6-5-2 2-4-5-4 8V4h16v11z"})}),execute:function execute(state,api){// Select everything
|
|
62643
62643
|
var newSelectionRange=selectWord({text:state.text,selection:state.selection});var state1=api.setSelectionRange(newSelectionRange);// Replaces the current selection with the image
|
|
62644
62644
|
var imageTemplate=state1.selectedText||'https://example.com/your-image.png';api.replaceSelection(""));// Adjust the selection to not contain the **
|
|
62645
62645
|
api.setSelectionRange({start:4+state1.selection.start,end:4+state1.selection.start+imageTemplate.length});}};
|
|
@@ -62686,7 +62686,7 @@ var title5={name:'title5',keyCommand:'title5',shortcuts:'ctrlcmd+5',value:'title
|
|
|
62686
62686
|
;// CONCATENATED MODULE: ./src/commands/title6.tsx
|
|
62687
62687
|
var title6={name:'title6',keyCommand:'title6',shortcuts:'ctrlcmd+6',value:'title6',buttonProps:{'aria-label':'Insert title6 (ctrl + 6)',title:'Insert title6 (ctrl + 6)'},icon:/*#__PURE__*/(0,jsx_runtime.jsx)("div",{style:{fontSize:12,textAlign:'left'},children:"Title 6"}),execute:function execute(state,api){if(state.selection.start===0||/\n$/.test(state.text)){api.replaceSelection('###### ');}else{insertAtLineStart('###### ',state.selection.start,api.textArea);}}};
|
|
62688
62688
|
;// CONCATENATED MODULE: ./src/commands/index.ts
|
|
62689
|
-
var commands_getCommands=function getCommands(){return[
|
|
62689
|
+
var commands_getCommands=function getCommands(){return[bold,italic,strikeThrough_strikethrough,hr,group([title1,title2,title3,title4,title5,title6],{name:'title',groupName:'title',buttonProps:{'aria-label':'Insert title',title:'Insert title'}}),divider,commands_link_link,quote,code_code,codeBlock,commands_comment_comment,commands_image_image,divider,unorderedListCommand,orderedListCommand,checkedListCommand];};var getExtraCommands=function getExtraCommands(){return[codeEdit,codeLive,codePreview,divider,fullscreen];};function getStateFromTextArea(textArea){return{selection:{start:textArea.selectionStart,end:textArea.selectionEnd},text:textArea.value,selectedText:textArea.value.slice(textArea.selectionStart,textArea.selectionEnd)};}var TextAreaTextApi=/*#__PURE__*/function(){function TextAreaTextApi(textArea){_classCallCheck(this,TextAreaTextApi);this.textArea=void 0;this.textArea=textArea;}/**
|
|
62690
62690
|
* Replaces the current selection with the new text. This will make the new selectedText to be empty, the
|
|
62691
62691
|
* selection start and selection end will be the same and will both point to the end
|
|
62692
62692
|
* @param text Text that should replace the current selection
|